package com.aidem.onecartoon.modules.article.service;

import com.aidem.onecartoon.common.constant.Constant;
import com.aidem.onecartoon.modules.article.entity.Admin;
import com.aidem.onecartoon.modules.article.mapper.AdminMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * LoginService
 *
 * @author aosun_wu
 * @date 2021-04-11 18:09
 */
@Service
public class LoginService {

	public static final String TEACHER = "老师";
	public static final String STUDENT = "学生";

	@Autowired
	private AdminMapper adminMapper;

	/**
	 * 登陆
	 * @param type 明文字符串 老师/学生
	 */
	public String doLogin(Integer number, String pwd, String type) {
		Map<String, Object> queryMap = new HashMap<>();
		queryMap.put("number", number);
		queryMap.put("pwd", pwd);
		queryMap.put("type", type);
		List<Admin> query = adminMapper.selectByMap(queryMap);
		if (CollectionUtils.isEmpty(query)) {
			return Constant.FAIL;
		}
		return Constant.SUCCESS;
	}

}
